#
#    Copyright (C) 2016 Francisco Javier Parra <franparpe@openmailbox.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

from cams import Cam
import sys


# mejorar la documentación de bezier que no se entiende nada
a = Cam()
# a.add_cam_section(0, 20, 0, 140, 0.1, 1, "7polynomial")
# a.add_cam_section(20, 20, 140, 200, 0.1, 1)
# a.add_cam_section(0, 50, 0, 100, 0.1, 1, "modified_trapezoidal")
# a.add_cam_section(50, -50, 0, 100, 0.1, 1, "5polynomial")
# a.add_cam_section(50, -50, 0, 100, 0.1, 1, "demicicloidal_Vi")
# a.add_cam_section(50, -50, 0, 100, 0.1, 1, "modified_trapezoidal")
#a.add_cam_section(0, 20, 0, 150, 0.1, 1, "bezier", 3)
#a.add_cam_section(20, 20, 150, 180, 0.1, 1)
a.add_cam_section(0, 30, 0, 80, 0.1, 1, "5polynomial")
a.add_cam_section(30, 30, 80, 120, 0.1, 1,)
a.add_cam_section(30, -30, 120, 180, 0.1, 1, "5polynomial")
# a.add_cam_section(0, 80, 0, 20, 0.1, 1, "7polynomial")
# a.add_cam_section(80, -80, 20, 180, 0.1, 1,)
# a.add_cam_section()

# Bezier tiene problemas

# a.add_cam_section(0,0,270,360,0.1,1)
# a.add_cam_section(0, 25, 0, 180, 0.1,1,"harmonic")
# a.add_cam_section(25, -25, 180, 360, 0.1, 1, "harmonic")
# a.add_cam_section(50,-50,0,100,0.01,1,"demiharmonic_Vi")
# a.add_cam_section(0, 50,0,100,0.01,1,"demiharmonic_Vf")
# rb, followertype, excentricity, beta, followerRadius, l1,l2
arguments = [85,"circular",80,0,20,200,200]
# rb, l1, l2sup, l2inf, l3sup,
# l3inf, followerType,
# excentricity, beta, separation, followerRadius, same
# Hacer que devuelva el parámetro del ángulo inicial del palpador de rotación
argumentsDemo = [110, 200, 0, 0, 200, 220, "angular_circular", 0, 20, 5, 10, True]
# Arguments for the constant width
# rb, l1, l2sup, l2inf
# followerType, excentricity, beta, separation, followerRadius
argumentsConstant = [80, 160, 120, 130, "plane", 10, 20, 180]
# Qué dc d(phi) = 2 R_b + s_max que el programa lo dé

if sys.argv[1] == "0":
    a.makeDXF(*arguments)
elif sys.argv[1] == "1":
    print(a.generate_cam_circular_follower(110,30,10))
    print(len(a.generate_cam_circular_follower(110,30,10)))
elif sys.argv[1] == "2":
    print(a.generate_flat_follower(110,5,5))
    print(len(a.generate_flat_follower(110,5,5)))
elif sys.argv[1] == "3":
    a.makeDXF(180,4,0,0,"Radio rodillo", 240, 5)
#    a.makeDXF(50,1,0,0,"Radio rodillo", 200, 5)
elif sys.argv[1] == "4":
    arguments.append(0)
    a.drawSection(*arguments)
elif sys.argv[1] == "5":
    a.makeDXF_d(*argumentsDemo)
elif sys.argv[1] == "6":
    a.makeDXF_c(*argumentsConstant)
else:
    a.PlotPosition()
    a.PlotVelocity()
    a.PlotAcceleration()
    a.PlotJerk()
